const { get, post } = require('../../request/index')
 
 
module.exports = {
  gridGet: function(parentId) {
   console.log(parentId);
    let prolist = wx.getStorageSync('prolist')==''?wx.getStorageSync('prolist'):JSON.parse(wx.getStorageSync('prolist'));
      
    
// 无权限
    // if(prolist.roleId.toString().includes(",") ){
    //   let a = prolist.roleId.split(",");
    //   var mapData11 = a.map(function (item) {
    //     return item - 0;
    //   });
    //   if(a.length>2){
    //     return get(`/app/menu/getAppResource?mineId=${prolist.mineId}&parentId=${parentId}&roleId=${mapData11[0]}&roleId=${mapData11[1]}&roleId=${mapData11[2]}`)
    //   }else{
    //     return get(`/app/menu/getAppResource?mineId=${prolist.mineId}&parentId=${parentId}&roleId=${mapData11[0]}&roleId=${mapData11[1]}`) 
    //   }
    // }else{
    //   return get(`/app/menu/getAppResource?mineId=${prolist.mineId}&parentId=${parentId}&roleId=${prolist.roleId}`)
    // }

// 有权限
if(prolist.roleId){
  if(prolist.roleId.toString().includes(",") ){

    let a = prolist.roleId.split(",");
    var mapData11 = a.map(function (item) {
      return item - 0;
    });
    if(a.length>2){
      return get(`/app/menu/getAppResourceNew?mineId=${prolist.mineId}&parentId=${parentId}&roleId=${mapData11[0]}&roleId=${mapData11[1]}&roleId=${mapData11[2]}&systemId=2`)
    }else{
      return get(`/app/menu/getAppResourceNew?mineId=${prolist.mineId}&parentId=${parentId}&roleId=${mapData11[0]}&roleId=${mapData11[1]}&systemId=2`) 
    }
  }else{
    return get(`/app/menu/getAppResourceNew?mineId=${prolist.mineId}&parentId=${parentId}&roleId=${prolist.roleId}&systemId=2`)
  }
}
// if(prolist.roleId==null){
//   console.log(prolist.roleids);
//       let str = ''
//       for (let i = 0; i < prolist.roleids.length; i++) {
//         console.log(prolist.roleids[0]);
//           str+=`&roleId=${prolist.roleids[i]}`    
//       }
//       str.slice(1);

//    return get(`/app/menu/getAppResourceNew?mineId=${prolist.mineId}&parentId=${parentId}&${str}&systemId=2`)
    
  
// }

   
   

    
  },

  login: function(code) {
    return post('wxlogin',{
      code: code
    })
  },

  dailyjh:function(){
    let prolist = wx.getStorageSync('prolist')==''?wx.getStorageSync('prolist'):JSON.parse(wx.getStorageSync('prolist'))
    return post('/checkPlan/getList?currentPage=1&pageSize=100',{
      mineId: prolist.mineId,
    })
  }

  



}